<?php
class Controller_Setting_Cache extends Controller_Abstract
{
	function actionEbayListingAPICacheList()
	{
		$this->_view['title'] = 'ebay API 缓存管理列表';
		$cp = isset($_GET['cp']) ? $_GET['cp'] : 0;
		$ps = isset($_GET['ps']) ? $_GET['ps'] : 20;
		$this->_view['shop'] = Shop::getPlatformShopToArray();
		$this->_view['site'] = Q::ini('custom_flag/online_ebay_listing_site');
		$this->_view['type'] = Q::ini('custom_flag/online_ebay_listing_api_cache_type');
		$url_arr = Helper_BSS_Normal::buildCondition();
		$result = Online_Ebay_Listing_API_Cache::search($url_arr, $cp, $ps);
		if ($result['ack'] == SUCCESS)
		{
			$page = new Helper_BSS_Page($result['pagination'], url('Setting::Cache/EbayListingAPICacheList', $url_arr));
			$this->_view['page'] = $page->getPage();
			$this->_view['ebay_listing_api_cache_list'] = $result['data'];
		}
	}
	
	function actionEbayListingAPICacheClear()
	{
		$this->_view['title'] = 'ebay API 缓存文件清空';
		if(isset($_GET['ids']))
		{
			$ids = $_GET['ids'];
			$result = QDB::getConn()->execute("update online_ebay_listing_api_cache set filename='' where id in(".$ids.")");
			if ($result)
			{
				return $this->_redirectMessage('数据已清空', '正在返回..', $_SERVER['HTTP_REFERER'], SUCCESS);
			}
			else
			{
				return $this->_redirectMessage('数据清空失败', '清空失败的缓存文件ID为:'.$ids, $_SERVER['HTTP_REFERER'], FAILURE);
			}
		}
	}
}